/**
 * Created by IAN on 2016/10/14.
 */
$(function () {
    var sel = $.Params.create();
    sel.addParams("page",0);
    sel.addParams("rows",rows);

    getData("",0);

    //查询
    $("#searchBtn").on("click",function () {
        var selTitle = $("#searchVal").val();
        var selClassify = $("#selClassify").val();

        if(selTitle == undefined || selTitle == "undefined"){
            alert("查询的内容不能为undefined！");
        }else{
            getData(selTitle,selClassify);
        }
    })


    //获取数据
    function getData(title,type){
        getPageData(sel,getIP()+"liked/getLikes?title="+title+"&type="+type,function(data){
            if(data.success){
                var html = "";
                $.each(data.result, function(i,val) {
                    html+="<tr role='row'' class='even'><td>"+parseInt(i+1)+"</td><td class='sorting_1'>"+val.title+
                        "</td><td>"+val.dianzan+"</td>"+
                        "<td>"+val.shoucang+"</td>"
                            if(val.type==1001){
                                html+= "<td>大课堂</td>";
                            }else if(val.type==1002){
                                html+= "<td>分享汇</td>";
                            }else if(val.type==1003){
                                html+="<td>新闻</td>";
                            }
                       html+= "</tr>";
                });
                $("#listContainer").html(html);
            }
        })
    }
});
